package com.brayan.webapp.controller.general;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.http.HttpServletRequest;


/**
 * Helps to controll the gui elements.
 * @author Brayan
 *
 */
@ManagedBean
@RequestScoped
public class NavigationController {
	
	@Inject
	@Named("facesContext")
	private FacesContext facesContext;

	final static String EXTERNAL_PICS_CITY = "https://www.facebook.com/media/set/?set=a.10152541115798401.1073741831.657863400&type=1&l=147e0390b0";
	final static String EXTERNAL_PICS_APARTMENT = "https://www.facebook.com/media/set/?set=a.10152342873738401.1073741829.657863400&type=1&l=6ea6c6fe11";
	final static String EXTERNAL_PICS_LAND = "https://www.facebook.com/media/set/?set=a.10152475931403401.1073741830.657863400&type=1&l=95048ed559";

	private String urlPicsCity = EXTERNAL_PICS_CITY;
	private String urlPicsApartment = EXTERNAL_PICS_APARTMENT;
	private String urlPicsLand = EXTERNAL_PICS_LAND;
	
	private boolean isAdminArea = false;

	public String getUrlPicsCity() {
		return urlPicsCity;
	}

	public void setUrlPicsCity(String urlPicsCity) {
		this.urlPicsCity = urlPicsCity;
	}

	public String getUrlPicsApartment() {
		return urlPicsApartment;
	}

	public void setUrlPicsApartment(String urlPicsApartment) {
		this.urlPicsApartment = urlPicsApartment;
	}

	public String getUrlPicsLand() {
		return urlPicsLand;
	}

	public void setUrlPicsLand(String urlPicsLand) {
		this.urlPicsLand = urlPicsLand;
	}

	public boolean isAdminArea() {
		ExternalContext eCtx = facesContext.getExternalContext();
		HttpServletRequest srvlRequest = (HttpServletRequest)eCtx.getRequest();
		if(srvlRequest == null)
			return false;
		else
			return srvlRequest.getRequestURI().contains("/admin");
	}

	public void setAdminArea(boolean isAdminArea) {
		this.isAdminArea = isAdminArea;
	}
}
